//
//  DDJobfindersService.m
//  DingDongZP
//
//  Created by Jyh on 16/4/10.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDJobfindersService.h"

@implementation DDJobfindersService

+ (DDJobfindersService *)shareInstance
{
    static DDJobfindersService *share = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        share = [[DDJobfindersService alloc] init];
    });
    
    return share;
}

- (void)queryJobfindersWithPage:(NSString *)page
                   successBlock:(successBlock)successBlock
                      failBlock:(faileBlock)failBlock
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"jobfinders"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    if (page) {
        params[@"page"] = page;
    }
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager GET:URLString parameters:params success:successBlock failure:failBlock];
}

- (void)queryJobfindersDetailWithId:(NSString *)jobfinderId
                       successBlock:(successBlock)successBlock
                          failBlock:(faileBlock)failBlock
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"query_loggedin_resume"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    if (jobfinderId) {
        params[@"jobfinder_id"] = jobfinderId;
    }
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager POST:URLString parameters:params success:successBlock failure:failBlock];

}

- (void)queryJobfindersInterestingStatusWithJobfindeId:(NSString *)jobfinderId
                                          successBlock:(successBlock)successBlock
                                             failBlock:(faileBlock)failBlock
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"employer_query_interestedjobfinder"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    if (jobfinderId) {
        params[@"jobfinder_id"] = jobfinderId;
    }
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager POST:URLString parameters:params success:successBlock failure:failBlock];
}

- (void)markJobfindersInterestingStatusWithJobfindeId:(NSString *)jobfinderId
                                         successBlock:(successBlock)successBlock
                                            failBlock:(faileBlock)failBlock
{
    NSString *URLString = [[DDAPIGenerate sharedInstance] API:@"employer_toggle_interestedjobfinder"];
    
    NSMutableDictionary *params = [@{} mutableCopy];
    
    if (jobfinderId) {
        params[@"jobfinder_id"] = jobfinderId;
    }
    
    DDNetWorkManager *manager = [DDNetWorkManager shareManager];
    
    [manager POST:URLString parameters:params success:successBlock failure:failBlock];
}

- (void)queryBossAdsArray:(void (^)(NSArray *ads))callback
{
    NSString *requestUrlString = [[DDAPIGenerate sharedInstance] API:@"query_ads_employers"];
    
    [[DDNetWorkManager shareManager] GET:requestUrlString parameters:nil success:^(id responseObject) {
        NSInteger success = [responseObject[@"code"] integerValue];
        if (success) {
            NSArray *resultArray = responseObject[@"data"];
            if (resultArray) {
                callback(resultArray);
            } else {
                callback(nil);
            }
        } else {
            callback(nil);
        }
        
    } failure:^(id responseObject, NSError *error) {
        callback(nil);
    }];
}

@end
